package com.tlgen.controller;

import com.tlgen.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@RestController
public class UserController {

    @Autowired
    private UserService userService;

    /**
     * 导出excel
     * @param response
     * @throws IOException
     */
    @GetMapping("/user/excel")
    public void excelExport(HttpServletResponse response) throws IOException {
        userService.excelExport(response);
    }

    /**
     * 导入excel
     * @param file
     * @return
     * @throws IOException
     */
    @PostMapping("/user/excel")
    public String excelImport(@RequestParam("file") MultipartFile file) throws IOException {
        userService.excelImport(file);
        return "success";
    }
}
